package net.scalan.jpa.model;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;

@Entity
public class DBNotification implements Serializable {

    private static final long serialVersionUID = 1L;

    //==========================================================================
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    //==========================================================================
    @Column
    private Long dt;

    /**
     * @return the dt
     */
    public Long getDt() {
        return dt;
    }

    public String getDate(){
        SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd");
        String dateStr = dateformat.format(new Date(dt));
        return dateStr;
    }

    public String getTime(){
        SimpleDateFormat timeformat = new SimpleDateFormat("HH:mm:ss");
        String timeStr = timeformat.format(new Date(dt));
        return timeStr;
    }

    /**
     * @param dt the dt to set
     */
    public void setDt(Long dt) {
        this.dt = dt;
    }

    //==========================================================================
    @Column
    private String message;

    /**
     * @return the message
     */
    public String getMessage() {
        return message;
    }

    /**
     * @param message the message to set
     */
    public void setMessage(String message) {
        this.message = message;
    }

    //==========================================================================
    @ManyToOne
    private DBStation station;

    /**
     * @return the station
     */
    public DBStation getStation() {
        return station;
    }

    /**
     * @param station the station to set
     */
    public void setStation(DBStation station) {
        this.station = station;
    }

    //==========================================================================
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DBNotification)) {
            return false;
        }
        DBNotification other = (DBNotification) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "net.scalan.jpa.model." + this.getClass().getName() + "[id=" + id + "]";
    }
}
